import React, { PropTypes } from 'react';
import { Table, Popconfirm, Pagination } from 'antd';

// 状态转换
function convertStatus(status) {
  var showStatus = '未知';
  if (status == 2) {
    showStatus = '上传中';
  } else if (status == 3) {
    showStatus = '上传成功';
  } else if (status == 5) {
    showStatus = '转档中';
  } else if (status == 6) {
    showStatus = '转档成功';
  } else if (status == 10) {
    showStatus = '转档失败';
  } else if (status == 11) {
    showStatus = '上传失败';
  } else if (status == 100) {
    showStatus = '文件合并失败';
  } else if (status == 101) {
    showStatus = '文件合并成功';
  } else if (status == 102) {
    showStatus = '调用转档';
  } else if (status == 103) {
    showStatus = '上传源文件阶段';
  } else if (status == 104) {
    showStatus = '转换源文件阶段';
  } else if (status == 105) {
    showStatus = '转档文件已下载';
  } else if (status == 106) {
    showStatus = '取得文件MD5失败';
  } else if (status == 107) {
    showStatus = '文件MD5校验失败';
  } else if (status == 108) {
    showStatus = '用户取消显示';
  } else if (status == 999) {
    showStatus = '用户数据过期';
  }

  return showStatus;
}

function TransferFileList({
  total, current, loading, dataSource,
  onPageChange,
  onDeleteItem,
  onEditItem,
  onChangeStatusItem,
  }) {
  const columns = [{
    title: '文件名',
    dataIndex: 'uf_name',
    key: 'uf_name',  
  }, {
    title: '用户',
    dataIndex: 'user_id',
    key: 'user_id',
  }, {
    title: '上传文件大小(B)',
    dataIndex: 'uf_size',
    key: 'uf_size',
  }, {
    title: '状态',
    dataIndex: 'status',
    render: (status) => convertStatus(status),
  }, {
    title: '转出文件大小(B)',
    dataIndex: 'tf_size',
    key: 'tf_size',
  }];

  const pagination = {
    total: total,
    showTotal: total => `总共 ${total} 条数据`,
    showSizeChanger: true,
    showQuickJumper: true,
    onShowSizeChange(current, pageSize) {
      //console.log('Current: ', current, '; PageSize: ', pageSize);
    },
    onChange(current) {
      //console.log('Current: ', current);
    },
  };

  return (
    <div>
      <Table
        columns={columns}
        dataSource={dataSource}
        loading={loading}
        rowKey={record => record.id}
        pagination={pagination}
      />
      {/*<Pagination
        className="ant-table-pagination"
        showTotal={total => `总共 ${total} 条数据`}
        total={total}
        current={current}
        pageSize={10}
        onChange={onPageChange}
      />*/}
    </div>
  );
}

TransferFileList.propTypes = {
  onPageChange: PropTypes.func,
  onDeleteItem: PropTypes.func,
  onEditItem: PropTypes.func,
  dataSource: PropTypes.array,
  loading: PropTypes.any,
  total: PropTypes.any,
  current: PropTypes.any,
  onChangeStatusItem: PropTypes.func,
};

export default TransferFileList;
